home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRTRANS.C < prev    next >
Text File  |  1993-01-04  |  2KB  |  47 lines

  1.  
  2. /*  File   : strtrans.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 2 June 1984
  5.     Defines: strtrans()
  6.  
  7.     strtrans(dst, src, from, to)
  8.     copies characters from src[] to dst[], stopping when dst gets a  NUL
  9.     character,  translating  characters  in  from[] to the corresponding
  10.     characters in to[]. Courtesy of _str2map, if from or to is null  its
  11.     previous  value  will be used, and if both are NullS the table won't
  12.     be rebuilt.  Note that copying stops when a NUL is put  into  dst[],
  13.     which  can  normally  happen  only  when a NUL has been fetched from
  14.     src[], but if you have built your own translation table  it  may  be
  15.     earlier  (if  some  character  is mapped to NUL) or later (if NUL is
  16.     mapped to something else).  No value is returned.
  17.  
  18.     The VaxAsm version only works from strlen(src) < 2^16.
  19. */
  20.  
  21. #include "strings.h"
  22. #include "_str2map.h"
  23.  
  24. #if     VaxAsm
  25.  
  26. void strtrans(dst, src, from, to)
  27.     _char_ *dst, *src, *from, *to;
  28.     {
  29.         _str2map(0, from, to);
  30.         asm("movtuc $65535,*8(ap),$0,__map_vec,$65535,*4(ap)");
  31.         /*  That stops when the "escape" is found, and we want to move it */
  32.         asm("movb $0,(r5)");
  33.     }
  34.  
  35. #else  ~VaxAsm
  36.  
  37. void strtrans(dst, src, from, to)
  38.     register _char_ *dst, *src;
  39.     _char_ *from, *to;
  40.     {
  41.         _str2map(0, from, to);
  42.         while (*dst++ = _map_vec[*src++]) ;
  43.     }
  44.  
  45. #endif  VaxAsm
  46.  
  47.